from django.db import models

from django.utils.translation import ugettext_lazy as _
# Create your models here.

from teat_demo.base_model.base_model import BaseModel
from .manger import UserManager 

class User(BaseModel):
    username = models.CharField( _(u'账户'),max_length=20)
    age = models.IntegerField( _(u'年纪'))
    active = models.BooleanField( _(u'是否启用'), default =False)

    # 保留原有的
    objects = models.Manager()

    users = UserManager()

    class Meta:
        db_table = 'tb_user'
    
    def __str__(self):
        return self.username

# ---------------------------测试GraphQL model---------------------------------------
# Create your models here.
class Title(models.Model):
    title = models.CharField(max_length=255, verbose_name="标题")

    def __str__(self):
        return self.name

class Author(models.Model):
    name = models.CharField(max_length=255, verbose_name="作者姓名")

    def __str__(self):
        return self.name

class Book(models.Model):
    title = models.ForeignKey(Title, related_name='book_title', on_delete=models.CASCADE)
    author = models.ForeignKey(Author, related_name='book_author', on_delete=models.CASCADE)